package com.sunnay.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunnay.entity.AppUserHelperEntity;
import com.sunnay.entity.ShopHelperListEntity;
import com.sunnay.mapper.AppUserHelperMapper;
import com.sunnay.service.AppUserHelperService;
import com.sunnay.service.ShopHelperListService;
import com.sunnay.vo.auth.SystemUser;
import com.sunnay.vo.helper.HelperRequestVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AppUserHelperServiceImpl extends ServiceImpl<AppUserHelperMapper, AppUserHelperEntity> implements AppUserHelperService {

    @Resource
    private ShopHelperListService helperListService;

    @Override
    public List<AppUserHelperEntity> list(SystemUser systemUser) {
        return  this.list(Wrappers.<AppUserHelperEntity>lambdaQuery().eq(AppUserHelperEntity::getWxId,systemUser.getWxId()).orderByDesc(AppUserHelperEntity::getIsTop));
    }

    @Override
    public void updateInfo(HelperRequestVo requestVo, SystemUser systemUser) {
        ShopHelperListEntity update = new ShopHelperListEntity();
        update.setId(requestVo.getId());
        update.setShopUri(requestVo.getShopUri());
        update.setShopUt(requestVo.getShopUt());
        this.helperListService.updateById(update);
    }
}
